﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor.IMGUI.Controls;
using UnityEngine;

namespace SLUISystem
{
    public class EditorTree : TreeView
    {
        private TreeViewItem m_root;

        public EditorTree(TreeViewState treeViewState, float width)
            : base(treeViewState, CreateDefaultMultiColumnHeaderState(width))
        {
            
            Reload();
        }

        private static MultiColumnHeader CreateDefaultMultiColumnHeaderState(float treeViewWidth)
        {
            var columns = new[]
            {
                new MultiColumnHeaderState.Column
                {
                    headerContent = new GUIContent("Overview"),
                    contextMenuText = "Overview",
                    headerTextAlignment = TextAlignment.Left,
                    sortedAscending = false,
                    sortingArrowAlignment = TextAlignment.Right,
                    width = 300,
                    minWidth = 200,
                    maxWidth = 1000,
                    autoResize = true,
                    canSort = false,
                    allowToggleVisibility = true
                },
            };
            var state = new MultiColumnHeaderState(columns);
            return new MultiColumnHeader(state);
        }

        protected override TreeViewItem BuildRoot()
        {
            m_root = new TreeViewItem();
            m_root.AddChild(new TreeViewItem());
            m_root.AddChild(new TreeViewItem());

            return m_root;
        }
    }
}
